
const { ccclass, property } = cc._decorator;

@ccclass
export default class DeepClone extends cc.Component {

    //使用递归进行深拷贝
    static deepClone(obj: any) {
        if (typeof obj !== "object") {
            return obj;
        }
        let objCopy = Array.isArray(obj) ? [] : {};
        for (let key in obj) {
            objCopy[key] = this.deepClone(obj[key]);
        }
        return objCopy;
    }
}
